Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed false positives for function stubs #2927

Merged
merged 1 commit into from
May 26, 2019
Merged

Fixed false positives for function stubs #2927

merged 1 commit into from
May 26, 2019

Conversation

AWhetter
Copy link
Contributor

Description

This change fixes unused-argument and function-redefined getting raised for functions decorated with typing.overload.
unused-argument ignores these functions altogether. function-redefined does not treat them as actual definitions, both when checking the node itself and when looking for duplicate definition nodes.

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Related Issue

Close #1581

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 90.07% when pulling f2b2c25 on fix_1581 into b38a7c8 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 90.07% when pulling f2b2c25 on fix_1581 into b38a7c8 on master.

@coveralls
Copy link

coveralls commented May 21, 2019

Coverage Status

Coverage increased (+0.02%) to 90.105% when pulling 6167f2d on fix_1581 into a9cb1c7 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 90.07% when pulling f2b2c25 on fix_1581 into b38a7c8 on master.

Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Left two minor comments to check before merging.

defined_self = parent_frame[node.name]
# Ignore function stubs created for type information
defined_self = next(
local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to throw a sentinel in there with next((....), None) so we won't crash if we can't find a proper local.

return

# Don't check function stubs created only for type information
if utils.decorated_with(node, "typing.overload"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use is_overload_stub instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unused-argument, pointless-statement, and function-redefined with recommended use of typing.overload
3 participants